package TwoSeach;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: TwoSeach
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-11-04  11:34
 * @Description: TODO
 * @Version: 1.0
 */
public class 有效的完全平方数367 {

    public boolean isPerfectSquare(int num) {
        int left = 0;
        int right = num;
        boolean result=false;
        while (left <= right) {
            int mid = (left + right) >> 1;
            long square = (long) mid * mid;
            if (square == num) {
                return true;
            } else if (square < num) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return result;
    }
}
